package com.li.springbootproject.spring;

import com.li.springbootproject.spring.beanfactorypostprocessor.Car;
import com.li.springbootproject.spring.beanfactorypostprocessor.CarEngine;
import com.li.springbootproject.spring.beanfactorypostprocessor.SpecialBeanForEngine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 3/12/2022 4:57 PM
 */
@Configuration
public class BeanProduct {

    /**
     * 定义引擎 Bean
     *
     * @return SpecialBeanForEngine
     */
    @Bean
    public SpecialBeanForEngine specialBeanForEngine() {
        return new SpecialBeanForEngine();
    }

    /**
     * 定义汽车 Bean 依赖引擎 Bean
     *
     * @param carEngine 汽车引擎
     * @return Car
     */
    @Bean(initMethod = "start")
    public Car car(CarEngine carEngine) {
        Car car = new Car();
        car.setEngine(carEngine);
        return car;
    }


}
